'use strict';

/* Controllers */

app
// Flot Chart controller
    .controller('deleteFeatureCtrl', ['$scope', '$modal', '$http', '$stateParams', '$rootScope', '$timeout', '$filter', function ($scope, $modal, $http, $stateParams, $rootScope, $timeout, $filter) {
        $rootScope.clean($scope.app)
        $scope.info = {};
        $scope.info.features = [];
        $scope.info.id = "";
        $scope.info.selectFeature = {};
        $scope.onChange = function (info) {
            $scope.info.selectFeature = info;
        }

        $scope.getList = function () {
            $.ajax({
                type: "get",
                url: matrix_product_url + '/feature/getFeature?withAttr=0',
                async: false,
                success: function (data) {
                    $scope.info.features = data.data;
                }
            });
        };

        $scope.getList();

        $scope.delete = function () {
            var info = {};
            info.titleData = "提示";
            info.bodyData = "确定要删除功能点吗？";
            $rootScope.confirmWindow(info, function (data) {
                $http.get(matrix_product_url + "/feature/deleteFeature?featureId=" + $scope.info.id).success(function (data) {
                    if (data.code == 0) {
                        alert("删除成功");
                        $scope.getList();
                        $scope.info.selectFeature = {};
                    } else {
                        alert(data.desc)
                    }
                })
            })
        }

    }])